package org.zxb.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.zxb.demo.resolver.MultipartFileAllowValidator;
import org.zxb.demo.resolver.MultipartFileMaxSizeValidator;
import org.zxb.demo.resolver.MultipartFileNotAllowValidator;

/**
 * 文件校验类型配置
 *
 * @author zxb
 * @date 2022-04-08 10:27
 **/
@Configuration
public class MultipartFileVerifyConfig {

    @Bean
    public MultipartFileAllowValidator multipartFileAllowValidator() {
        return new MultipartFileAllowValidator();
    }

    @Bean
    public MultipartFileNotAllowValidator multipartFileNotAllowValidator(MultipartFileAllowValidator multipartFileAllowValidator) {
        return new MultipartFileNotAllowValidator(multipartFileAllowValidator);
    }

    @Bean
    @Primary
    public MultipartFileMaxSizeValidator multipartFileMaxSizeValidator(MultipartFileNotAllowValidator multipartFileNotAllowValidator) {
        return new MultipartFileMaxSizeValidator(multipartFileNotAllowValidator);
    }

}
